package com.xn.app.muying.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.sqlite.DBManager;
import com.xn.app.muying.util.BaseActivity;
import com.xn.app.muying.util.ToastUtil;
import com.zhuge.analysis.stat.ZhugeSDK;

/**
 * 检查科普
 * Created by gaoge on 2016/11/22.
 */
public class ScienceActivity extends BaseActivity implements View.OnClickListener {

    //返回键
    private ImageView img_back = null;
    //标题栏
    private TextView title_name = null;
    //孕前检查
    private LinearLayout progestation = null;
    //孕期检查
    private LinearLayout pregnancy = null;
    //动作
    private Intent intent = null;
    //医院ID
    private String antenatalCareHospitalId=null;
    //用户名
    private String userName=null;
    //数据库
    private DBManager db=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_science);
        //初始化组件
        initialization();
        //实现
        realize();
    }

    /**
     * 初始化组件，并给相应控件添加单击事件
     */
    private void initialization() {
        try {
            ZhugeSDK.getInstance().track(getApplicationContext(), "检查科普");
        } catch (Exception e) {
            e.printStackTrace();
        }
        db=new DBManager(this);
        title_name = (TextView) findViewById(R.id.title_name);
        img_back = (ImageView) findViewById(R.id.img_back);
        progestation = (LinearLayout) findViewById(R.id.progestation);
        pregnancy = (LinearLayout) findViewById(R.id.pregnancy);
        pregnancy.setOnClickListener(this);
        progestation.setOnClickListener(this);
        img_back.setOnClickListener(this);
    }

    /**
     * 功能实现
     */
    private void realize() {
        //设置标题
        title_name.setText("检查科普");
        intent = new Intent();
    }

    /**
     * 单击事件
     *
     * @param view
     */
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            //返回键
            case R.id.img_back:
                finish();
                break;
            //孕前检查
            case R.id.progestation:
                intent.setClass(ScienceActivity.this, KePuActivity.class);
                startActivity(intent);
                break;
            //孕期检查
            case R.id.pregnancy:
                userName=db.select("tel");
                if(userName!=null&&!userName.equals("")&&!userName.equals("null")){

                    intent.setClass(ScienceActivity.this, ChanJianListActivity.class);
                    startActivity(intent);
                }else{
                    //如果没有登陆，调整到登陆页面
                    startActivity(new Intent(ScienceActivity.this, DengLuActivity.class));
                }
                break;
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}
